package com.beerbear.nacosfirstservice.controller;

import com.beerbear.nacosfirstservice.config.NacosCentralProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author: Beer Bear
 */
@RestController
@RequestMapping("/firstService")
//@RefreshScope
public class FirstNacosModuleController {

//    @Value("${application.username}")
//    private String userName;
//
//    @GetMapping("who_are_u")
//    public String whoAreYou(){
//        return "我是"+userName;
//    }

    @Autowired
    private NacosCentralProperties nacosProperties;

    @GetMapping("who_are_u")
    public String whoAreYou(){
        return "我是"+nacosProperties.getUsername()+",该项目的目的是"+nacosProperties.getGoal();
    }

    @GetMapping("/call")
    public HashMap getMyService(){
        HashMap response = new HashMap();
        response.put("success","恭喜你调用eureka-service-first中的接口成功！");
        System.out.println(response);
        return response;
    }
}
